import request from '@/utils/request'

const baseURL = '/admin/product'

// 获取商品列表
export const getProductList = (params) => {
  return request.get(`${baseURL}/list`, { 
    params: {
      ...params,
      pageNum: params.pageNum || 1,
      pageSize: params.pageSize || 10
    }
  })
}

// 获取商品详情
export const getProductDetail = (id) => {
  return request.get(`${baseURL}/detail`, { params: { id } })
}

// 新增商品
export const addProduct = (data) => {
  return request.post(`${baseURL}/add`, data)
}

// 更新商品
export const updateProduct = (data) => {
  return request.post(`${baseURL}/update`, data)
}

// 删除商品
export const deleteProduct = (id) => {
  return request.delete(`${baseURL}/delete`, { params: { id } })
}

// 商品上下架
export const toggleProductStatus = (id) => {
  return request.post(`${baseURL}/start`, null, {
    params: { id }
  })
}

// 上传商品图片
export const uploadProductImages = (formData) => {
  return request.post(`${baseURL}/upload/product`, formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

 